package Test01;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Stack;

public class Test2 {
}

class CQueue {

    Deque<Integer> stack1;
    Deque<Integer> stack2;
    public CQueue() {
    stack1=new LinkedList<>();
    stack2=new LinkedList<>();
    }

    public void appendTail(int value) {
    stack1.push(value);
    }

    public int deleteHead() {
    if(stack2.isEmpty()){
        while (!stack1.isEmpty()){
            stack2.push(stack1.pop());
        }
    }
    if(stack1.isEmpty()){
        return -1;
    }else {
        int element=stack2.pop();
        return element;
    }
    }
}

class MinStack {
Deque<Integer> stackA;
Deque<Integer> stackB;
    /** initialize your data structure here. */
    public MinStack() {
        stackA=new LinkedList<>();
        stackB=new LinkedList<>();
    }

    public void push(int x) {
        stackA.push(x);
        if(stackB.isEmpty()){
            stackB.push(x);
        }else {
            if(x<stackB.peek()){
                stackB.push(x);
            }
        }
    }

    public void pop() {
        if(!stackA.isEmpty()) {
            stackA.pop();
            if (!stackB.isEmpty()) {
                stackB.pop();
            }
        }
    }

    public int top() {
         Integer peek = stackA.peek();
         return peek;
    }

    public int min() {
         Integer peek = stackB.peek();
        return peek;
    }
}